﻿using B.S.NewMedical.Domain.Appointment;
using B.S.NewMedical.Domain.MobileService;
using B.S.NewMedical.Domain.Doctor;
using B.S.NewMedical.Domain.Hospital;
using B.S.NewMedical.Domain.User;
using Microsoft.EntityFrameworkCore;
using B.S.NewMedical.Domain.Order;
using System.Text.Json;

namespace B.S.NewMedical.Infrastructure
{
    public class MyDbcontext : DbContext
    {
        public MyDbcontext(DbContextOptions options) : base(options)
        {
        }

        /// <summary>
        /// 收费表
        /// </summary>
        public DbSet<Charge> charges { get; set; }
        /// <summary>
        /// 医生表
        /// </summary>
        public DbSet<Doctor> doctors { get; set; }
        /// <summary>
        /// 检验申请表
        /// </summary>
        public DbSet<Laborder> laborders { get; set; }
        /// <summary>
        /// 医疗卡表
        /// </summary>
        public DbSet<MedicalCard> medicalCards { get; set; }
        /// <summary>
        /// 处方主表
        /// </summary>
        public DbSet<Prescription> prescriptions { get; set; }
        /// <summary>
        /// 处方明细表
        /// </summary>
        public DbSet<PrescriptionItem> prescriptionItems { get; set; }
        /// <summary>
        /// 挂号表
        /// </summary>
        public DbSet<Registration> registrations { get; set; }
        /// <summary>
        /// 就诊表
        /// </summary>
        public DbSet<Visit> visits { get; set; }
        /// <summary>
        /// 轮播图实体
        /// </summary>
        public DbSet<CarouselModel> CarouselModels { get; set; }
        /// <summary>
        /// 医院实体
        /// </summary>
        public DbSet<HospitalModel> HospitalModel { get; set; }
        /// <summary>
        /// 医院类型实体
        /// </summary>
        public DbSet<HospitalTypeModel> HospitalTypeModel { get; set; }
        /// <summary>
        /// 医院科室关联实体
        /// </summary>
        public DbSet<HospitalDepartmentModel> HospitalDepartmentModel { get; set; }
        /// <summary>
        /// 患者实体
        /// </summary>
        public DbSet<PatientModel> PatientModel { get; set; }
        /// <summary>
        /// 历史就诊记录实体
        /// </summary>
        public DbSet<VisitRecordModel> VisitRecordModel { get; set; }
        /// <summary>
        /// 就诊类型实体
        /// </summary>
        public DbSet<VisitTypeModel> VisitTypeModel { get; set; }
        /// <summary>
        /// 检查项目表
        /// </summary>
        public DbSet<CheckupItemModel> CheckupItemModel { get; set; }
        /// <summary>
        /// 检查项目类别实体
        /// </summary>
        public DbSet<CheckupCategoryModel> CheckupCategoryModel { get; set; }
        /// <summary>
        /// 科室实体
        /// </summary>
        public DbSet<DepartmentModel> DepartmentModel { get; set; }
        /// <summary>
        /// 药品类别实体
        /// </summary>
        public DbSet<DrugCategoryModel> DrugCategoryModel { get; set; }
        /// <summary>
        /// 药品信息实体
        /// </summary>
        public DbSet<DrugInfoModel> DrugInfoModel { get; set; }
        /// <summary>
        /// 职位
        /// </summary>
        public DbSet<JobTitleModel> JobTitleModel { get; set; }
        /// <summary>
        /// 开单申请表
        /// </summary>
        public DbSet<PrescriptionApplicationModel> PrescriptionApplicationModel { get; set; }
        /// <summary>
        /// 开单记录明细表
        /// </summary>
        public DbSet<PrescriptionDetailModel> PrescriptionDetailModel { get; set; }
        /// <summary>
        /// 检查项目
        /// </summary>
        public DbSet<TestItemModel> TestItemModel { get; set; }
        /// <summary>
        /// 检查项目类别
        /// </summary>
        public DbSet<TestCategoryModel> TestCategoryModel { get; set; }


        /// <summary>
        /// 咨询分类表
        /// </summary>
        public DbSet<ConsultCategory> consultCategories { get; set; }
        /// <summary>
        /// 咨询问题表
        /// </summary>
        public DbSet<ConsultQuestion> consultQuestions { get; set; }
        /// <summary>
        /// 医生回答表
        /// </summary>
        public DbSet<ConsultAnswer> consultAnswers { get; set; }
        /// <summary>
        /// 用户互动表
        /// </summary>
        public DbSet<ConsultInteract> consultInteracts { get; set; }
        /// <summary>
        /// 问题标签映射表
        /// </summary>
        public DbSet<ConsultTagMap> consultTagMaps { get; set; }
        /// <summary>
        /// 服务类别表
        /// </summary>
        public DbSet<PriceServiceType> priceServiceTypes { get; set; }
        /// <summary>
        /// 价格条目表
        /// </summary>
        public DbSet<PriceItem> priceItems { get; set; }
        /// <summary>
        /// 就医指南分类表
        /// </summary>
        public DbSet<GuideCategory> guideCategories { get; set; }
        /// <summary>
        /// 就医指南文章表
        /// </summary>
        public DbSet<GuideArticle> guideArticles { get; set; }
        /// <summary>
        /// 就医指南正文内容表
        /// </summary>
        public DbSet<GuideContent> guideContents { get; set; }
        /// <summary>
        /// 就医指南反馈表
        /// </summary>
        public DbSet<GuideFeedback> guideFeedbacks { get; set; }
        /// <summary>
        /// 处方流转订单管理
        /// </summary>
        public DbSet<PrescriptionModel> Prescription { get; set; }
        /// <summary>
        /// 退款申请
        /// </summary>
        public DbSet<RefundModel> Refund { get; set; }
        /// <summary>
        /// 问诊单管理
        /// </summary>
        public DbSet<ConsultationModel> Consultation { get; set; }
        /// <summary>
        /// 挂号订单管理
        /// </summary>
        public DbSet<RegisterModel> Register { get; set; }
        /// <summary>
        /// 药品管理
        /// </summary>
        public DbSet<MedicineModel> Medicine { get; set; }
        /// <summary>
        /// 用户管理
        /// </summary>
        public DbSet<UserModel> UserModel { get; set; }
        /// <summary>
        /// 权限类型表
        /// </summary>
        public DbSet<PermissionTypeModel> permissionTypeModels { get; set; }
        /// <summary>
        /// 用户权限表
        /// </summary>
        public DbSet<UserPermissionModel> userPermissionModels { get; set; }
        /// <summary>
        /// 权限表
        /// </summary>
        public DbSet<PermissionModel> permissionModels { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            
            // 明确指定HospitalDepartmentModel的表名
            modelBuilder.Entity<HospitalDepartmentModel>()
                .ToTable("HospitalDepartments");
        }
    }
}
